package com.qianfeng.missfood.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.lidroid.xutils.BitmapUtils;
import com.qianfeng.missfood.R;

import java.util.List;

/**
 * Created by Administrator on 2015/7/20.
 */
public abstract class AppBaseAdapter<E> extends BaseAdapter {
    public List<E> list;
    public Context context;
    public LayoutInflater inflater;
    public BitmapUtils bitmapUtils;

    public AppBaseAdapter(List<E> list, Context context) {
        this.list = list;
        this.context = context;
        inflater = LayoutInflater.from(context);
        bitmapUtils = new BitmapUtils(context);
        bitmapUtils.configDefaultLoadingImage(R.mipmap.shop_menu_moren_img);
        bitmapUtils.configDefaultLoadFailedImage(R.mipmap.shop_menu_moren_img);

    }

    @Override
    public int getCount() {

        return list != null && list.size() > 0 ? list.size() : 0;
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        return getItemView(position, convertView, parent);
    }

    public abstract View getItemView(int position, View convertView, ViewGroup parent);
}
